/*
 * 常用操作
 * *
 */
    function commonOperation(layoutId,url,pageLimit) {
        var tokenId = antUtil.getSes('tokenId');
        var appId = antUtil.getSes('appId');
        var userId = antUtil.getSes('userId');

        //常用操作
        getCommonOperInfo(appId,'COMMON_OPERATION',userId,layoutId,'commonOper',pageLimit);

        //我要办
        getCommonOperInfo(appId,'WORK_TODO',userId,layoutId,'workToDo',pageLimit);

        //常用报表
        getCommonOperInfo(appId,'WORK_TODO',userId,layoutId,'workToDo',pageLimit);

        //我的单据
        getCommonOperInfo(appId,'COMMON_BILLS',userId,layoutId,'commonBills',pageLimit);

        //点击详细打开链接

        $('.hidContent ul li').click(function(){
            var url = $(this).attr('data-url');
            openURl(url);
        });

}

/*
 * 获取常用操作
 *
 */

function getCommonOperInfo(appId,pageId,userId,layoutId,tabId,pageLimit){
    $.ajax({
        url: "commonOperation/selectCommonOperation",
        type: 'GET',
        dataType: "json",
        async:false,
        data: {
            appId:appId,
            pageId:pageId,
            userId: userId
        },
        success: function (data) {

            var html = '';
            var limit;
            var num = data.length;
            if (num < pageLimit - 1) {
                limit = num;
            } else {
                limit = pageLimit;
            }
            html+='<ul class="list-hid">';
            for (var i = 0; i < limit; i++) {
                html += '<li data-url="'+data[i].url +'" ><a href="#" class="text-m">' + data[i].title + '</a></li>';
            }
            html+='</ul>';

            $('#' + layoutId).find('#'+tabId).html(html);

        }
    })
}

/*
 * 预警信息
 * *
 */
function remindInfo(layoutId,url,pageLimit) {

    var userId = antUtil.getSes('userId');
    var tokenId = antUtil.getSes('tokenId');

    //未读
    $.ajax({
        url: "message/SearchMessageInfoByStatus",
        type: 'GET',
        dataType: "json",
        data: {
            tokenId: tokenId,
            userId: userId,
            status: '0'
        },
        success: function (data) {
            var html = '';
            var limit;
            var num = data.length;
            if (num < pageLimit - 1) {
                limit = num;
            } else {
                limit = pageLimit - 1;
            }
            for (var i = 0; i < limit; i++) {
                html += '<li data-id="'+data[i].eventCode +'" data-appid="'+data[i].appId +'" data-url="'+data[i].url +'" ><a href="#">' + data[i].title + '</a><span class="time">' + data[i].busiDate + '</span></li>';
            }

            $('#' + layoutId).find('.portletContent #mesRemain-list1').html(html);

            //消息详细
            $('.mesRemain .portletContent ul li ').click(function(){

                var id= $(this).attr('data-id');

                var url =$(this).attr('data-url');

                // $('#iframeModal').attr('data-id',id);
                // $('#iframeModal').attr('src','/init/messageDetail');
                // $('#myModal .modal-header .modal-title').html('预警信息');
                // // $('#myModal').modal();
                //
                // var url ='http://192.168.0.19:7001/portal.integration/f3portal/f3portal.jsp?&jnlp=pay&uid=17192&usercode=021001001007&username=cs&passwd=c4ca4238a0b923820dcc509a6f75849b&setyear=2018&menuid=900221212002&moduleid=215201002&menuname=1115&sid=17192&sysapp=900&rgcode=310000&app=/gfmis/login&isfrom=portal';
                //

                //更新消息状态

                //系统编码
                var appId = $(this).attr('data-appid');
                $.ajax({
                    url: "message/UpdateMessageServiceINF",
                    type: 'GET',
                    dataType: "json",
                    data: {
                        tokenId: tokenId,
                        UserId: userId,
                        EventCode:id,
                        AppId:appId
                    },
                    success: function (data) {
                        // window.open (url, '_blank', 'width=' + screen.width + ',height=' + window.screen.availHeight + ', top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');
                        remindInfo(layoutId,url,pageLimit);
                    }
                });

            });
        }
    })



    //已读
    $.ajax({
        url: "message/SearchMessageInfoByStatus",
        type: 'GET',
        dataType: "json",
        data: {
            tokenId: tokenId,
            userId: userId,
            status: '1'
        },
        success: function (data) {
            var html = '';
            var limit;
            var num = data.length;
            if (num < pageLimit - 1) {
                limit = num;
            } else {
                limit = pageLimit - 1;
            }
            for (var i = 0; i < limit; i++) {
                html += '<li data-id="'+data[i].eventCode +'" data-url="'+data[i].url +'"><a href="#">' + data[i].title + '</a><span class="time">' + data[i].busiDate + '</span></li>';
            }

            $('#' + layoutId).find('.portletContent #mesRemain-list2').html(html);

            //消息详细
            $('.mesRemain .portletContent ul li ').click(function(){

                var id= $(this).attr('data-id');
                var url =$(this).attr('data-url');
                if(url==null ||url=='' || url=='null'){
                    $('#iframeModal').attr('data-id',id);
                    $('#iframeModal').attr('src','messageDetail');
                    $('#myModal .modal-header .modal-title').html('预警信息');
                    $('#myModal').modal();
                    return;
                }

                if(url.indexOf('http://')==-1 ){
                    url='http://'+url;
                }
                //判断当是F3系统页面时处理公共applet
                if(url.indexOf('f3portal') !=-1){
                    $('#layoutHtml').html('');
                    // var data_url ='http://192.168.0.19:7001/portal.integration/f3portal/f3portal.jsp?&jnlp=pay&uid=17192&usercode=021001001007&username=cs&passwd=c4ca4238a0b923820dcc509a6f75849b&setyear=2018&menuid=900221212002&moduleid=215201002&menuname=1115&sid=17192&sysapp=900&rgcode=310000&app=/gfmis/login&isfrom=portal';
                    var html = '<iframe id="iframeModal" data-url ="'+url+'" style="overflow-y: hidden;overflow-x: hidden; height:100%;" src="'+url+'"   width="100%" height="100%" frameborder="0" data-id=""></iframe>';
                    $('#right-content').html(html);
                }else if(url.indexOf('bappr') !=-1){

                    $('#iframeModal').attr('data-id',id);
                    $('#iframeModal').attr('src','messageDetail');
                    $('#myModal .modal-header .modal-title').html('预警信息');
                    $('#myModal').modal();
                    return;
                }else{

                    // var pageId = treeNode.page_id;
                    $('#layoutHtml').html('');
                    var html = '<iframe id="iframeModal" data-url ="'+url+'" style="overflow-y: hidden;overflow-x: hidden; height:100%;" src="'+url+'"   width="100%" height="100%" frameborder="0" data-id=""></iframe>'
                    $('#right-content').html(html);
                }

            });
        }
    })
}

    /*
     * 流程追踪
     * *
     */

function flowTracing(layoutId,url,pageLimit){

    var userId = antUtil.getSes('userId');
    var nd = antUtil.getSes('nd');
    var tokenId = antUtil.getSes('tokenId');

    // //统一报表
    // var JQurl1='http://192.168.0.90:9797/service?';
    // //部门决算
    // var JQurl2='http://192.168.0.90:9797/bmjsworktodo?';
    // //闻政 绩效
    // var WZurl1='http://192.168.0.89:7005/bappr/services/WaitingImplServiceInfo?wsdl';
    // //预算
    // var YSurl1='http://192.168.0.19:7001/gfmis/services/PortalContentWebServiceImpl?wsdl';



    //统一报表
    var JQurl1='http://10.93.244.50:6666/service?';
    //部门决算
    var JQurl2=' http://10.93.244.50:6667/bmjsworktodo?';
    //闻政 绩效
    var WZurl1='http://10.93.244.50:7971/bappr/services/WorkflowTraceUndoInfo?wsdl';
    //闻政 绩效
    var WZurl2='http://10.93.244.50:7971/bappr/services/WorkflowTraceDoneInfo?wsdl';
    //预算
    var YSurl1='http://10.93.244.50:9009/gfmis/services/PortalContentWebServiceImpl?wsdl';



    //未办结
    $.ajax({
        url : "flowTracing/getToDoFlowTracing",
        type : 'GET',
        dataType : "json",
        data : {
            tokenId:tokenId,
            userId:userId,
            nd:nd,
            // JQurl1:JQurl1,
            // JQurl2:JQurl2,
            // WZurl1:WZurl1,
            // YSurl1:YSurl1,
            type:'1'
        },
        success : function(data) {
            var html='';
            var limit;
            var num = data.length;
            if(num < pageLimit-1){
                limit=num;
            }else{
                limit=pageLimit-1;
            }
            for(var i=0;i<limit;i++){
                html+='<li data-url="'+data[i].url+'"><a href="#">'+data[i].name+'</a><span class="c money">'+data[i].number+'&nbsp;笔</span></li>';
            }

            $('#'+layoutId).find('.portletContent .process-list1').html(html);


            //详细
            $('.process-list1  li').click(function(){
                var url = $(this).attr('data-url');

                openURl(url);

            });


        }
    })


    //已办结
    $.ajax({
        url : "flowTracing/getDoneFlowTracing",
        type : 'GET',
        dataType : "json",
        data : {
            tokenId:tokenId,
            userId:userId,
            nd:nd,
            // JQurl1:JQurl1,
            // JQurl2:JQurl2,
            // WZurl1:WZurl2,
            // YSurl1:YSurl1,
            type:'2'
        },
        success : function(data) {
            var html='';
            var limit;
            var num = data.length;
            if(num < pageLimit-1){
                limit=num;
            }else{
                limit=pageLimit-1;
            }
            for(var i=0;i<limit;i++){
                html+='<li data-url="'+data[i].url+'"><a href="#">'+data[i].name+'</a><span class="c money">'+data[i].number+'&nbsp;笔</span></li>';
            }

            $('#'+layoutId).find('.portletContent .process-list2').html(html);

            //详细
            $('.process-list2  li').click(function(){
                var url = $(this).attr('data-url');

                openURl(url);

            });
        }
    })

}

/*
 * 待办查询
 * *
 */

function toDoList(layoutId,url,pageLimit){

var userId = antUtil.getSes('userId');
var nd = antUtil.getSes('nd');
var tokenId = antUtil.getSes('tokenId');

//清空待办dom
$('#'+layoutId).find('.portletContent ul').html('');

    //统一报表
    // var JQurl1='http://192.168.0.90:9797/service?';
    // //部门决算
    // var JQurl2='http://192.168.0.90:9797/bmjsworktodo?';
    // //闻政
    // var WZurl1='http://192.168.0.89:7005/bappr/services/WaitingImplServiceInfo?wsdl';
    // //预算
    // var YSurl1='http://192.168.0.19:7001/gfmis/services/PortalContentWebServiceImpl?wsdl';


    //统一报表
    var JQurl1='http://10.93.244.50:6666/service?';
    //部门决算
    var JQurl2='http://10.93.244.50:6667/bmjsworktodo?';
    //闻政
    var WZurl1='http://10.93.244.50:7971/bappr/services/WaitingImplServiceInfo?wsdl';
    //预算
    var YSurl1='http://10.93.244.50:9009/gfmis/services/PortalContentWebServiceImpl?wsdl';

//待办
    $.ajax({
        url : "todoWork/getWorkTask",
        type : 'GET',
        dataType : "json",
        data : {
            tokenId:tokenId,
            userId:userId,
            // JQurl1:JQurl1,
            // JQurl2:JQurl2,
            // WZurl1:WZurl1,
            // YSurl1:YSurl1,
            type:'0',
            nd:nd
        },
        success : function(data) {
            var html='';
            var limit;
            var num = data.length;
            if(num < pageLimit-1){
                limit=num;
            }else{
                limit=pageLimit-1;
            }
            for(var i=0;i<limit;i++){
                html+='<li data-url="'+data[i].url+'"><span class="icon-r"></span><a href="#">'+data[i].name+'</a><span class="count">'+data[i].number+'</span></li>';
            }

            $('#'+layoutId).find('.portletContent ul').append(html);
            //待办详细
            $('.toDoList ul li').click(function(){
                var url = $(this).attr('data-url');

                openURl(url);

                // if(url.indexOf('http://')==-1 ){
                //     url='http://'+url;
                // }
                //
                // //判断当是F3系统页面时处理公共applet
                // if(url.indexOf('f3portal') !=-1){
                //     $('#layoutHtml').html('');
                //     var html = '<iframe id="iframeModal" data-url ="'+url+'" style="overflow-y: hidden;overflow-x: hidden; height:100%;" src="'+url+'"   width="100%" height="100%" frameborder="0" data-id=""></iframe>';
                //     $('#right-content').html(html);
                // }else{
                //
                //     window.open (url, '_blank', 'width=' + screen.width + ',height=' + window.screen.availHeight + ', top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');
                //
                // }


            });
        }
    })


}





/*
 * 支出进度查询
 * *
 */

function accountPayment(layoutId,url,pageLimit) {

    var html = '<div class="topTable">';
        html+='<span class="budgetSpan">资金来源:</span>';
        html+='<select id="budgetSelect" class="budgetSelect">';
        html+='<option value="0">全部</option>';
        html+='<option value="1">基本支出</option>';
        html+='<option value="2">项目支出</option>';
        html+='<option value="3">政府采购</option>';
        html+='<option value="4">公务卡</option>';
        html+='</select>';
        html+='</div>';
        html+='<div class="topTable">';
        html+='<span >指标金额 :<span class="moneyNum">30,000.00</span></span>';
        html+='<span >支付金额 :<span class="moneyNum">10,000.00</span></span>';
        html+='<span >指标余额 :<span class="moneyNum">20,000.00</span></span>';
        html+='</div>';
        html+='<div id="accountPaymentTable" style="width:100%;height:150px;"></div>';

    $('#'+layoutId).html(html);

	var jsonSeries;
				jsonSeries = [{
				name: '指标余额',
				data: [350]
			}, {
				name: '在途支付',
				data: [10]
			}, {
				name: '支付金额',
				data: [150]
			}

		];

	//单位支出
	$('#accountPaymentTable').highcharts({
		chart: {
			type: 'bar'
		},
		credits: {
			enabled: false
		},
		exporting: {
			enabled: false
		},
		title: {
			text: ''
		},
		xAxis: {　　
			
			labels: {
				enabled: true
			},
			tickWidth: 0,
			categories: ['']
		},
		yAxis: {
			min: 0,
			title: {
				text: ''
			},
			opposite:true,
			labels: { //y轴刻度文字标签  
				formatter: function() {
					return this.value + '%'; //y轴加上%  
				}
			},
　　plotLines: [{   //一条延伸到整个绘图区的线，标志着轴中一个特定值。
                    color: 'red',
                    dashStyle: 'Dash', //Dash,Dot,Solid,默认Solid
                    width: 3,
                    value: 55,  //y轴显示位置
                    zIndex: 5,
                    label: {
			                text: '<span style="color:red">▲   <span><div><span style="color:red">'+56+'%</span></div>',//+xsjd+'%',//xsjd+'%',
			                align: 'left',
			                rotation: 0,
			                x: -9,
			                y: 80,
			                style: {
			                    'color': 'red',
			                    'fontWeight': 'bold',
			                    'font-size': '20px',
			                    'cursor': 'default'
			                }
			            },
                }]
		},
		tooltip: {
			pointFormat: '<span style="color:{series.color}">{series.name}</span>: <b>{point.y} (万元)</b> ({point.percentage:.0f}%)<br/>',
			shared: false,
			split: true
		},
		colors: ['#D3EBFD','#3448A1','#F66902'],
		legend: {
			reversed: true,
			layout: 'horizontal',
			align: 'center',
			verticalAlign: 'top',
			x: 200,
			y: -10,
			floating: false,
			borderWidth: 0,
			backgroundColor: ((Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'),
			shadow: false
		},
		plotOptions: {
			series: {
				stacking: 'percent',
				dataLabels: {
					enabled: true,
					color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white',
					style: {
						textShadow: '0 0 3px green'
					},
					formatter: function() {
						return this.point.percentage.toFixed(1) + '%';
						

					}
				},
				events: {
					click: function(event) {
                        var zfjd = event.point.series.name;
                        var url="https://www.baidu.com";
                        window.open (url, '_blank', 'width=' + screen.width + ',height=' + window.screen.availHeight + ', top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');
					}
				}
			}
		},
		series: jsonSeries
	});
};

